package com.zjb.wxlisener.control;

import com.zjb.wxlisener.JavaBean.Music;
import com.zjb.wxlisener.JavaBean.Result;
import com.zjb.wxlisener.service.MusicListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/music")
@CrossOrigin(origins = "*", allowedHeaders = "*")
public class MusicListControl {
    @Autowired
    MusicListService musicListService;
    @GetMapping("/getmusic")
    public Result getMusicByid(@RequestParam("id") Integer id){
        List<Music> musicList = musicListService.getMusicList(id);
        System.out.println(musicList);
        if (musicList==null){
            return Result.error("error");
        }else {
            return Result.success(musicList);
        }
    }
    @GetMapping("/geturl")
    public String getMusicUrlByid(Integer id){
        String url = musicListService.getMusicUrlByid(id);
        return url;
    }
}
